<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{person.name}} {{person.age}} {{person.address}}{{arr}}
        <button @click="change">change</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                person:{
                    name:'lili'
                },
                arr:[1,2,3,4]
            },
            methods:{
                change(){
                    // this.arr[1] = 'str'
                    // this.arr.splice(1,1,'str');
                    // this.arr.length = 0;
                    this.arr.splice(0);
                }
            }
        })

        // vm.person.age = 18;  

        // vm.id = 10;

        //vm.$set(vm.person,'age',10)

        // vm.$set(vm.person,'age',10);

        // vm.$set(vm.$data,'id',10)  不能直接在data对象内直接添加属性

        // Vue.set(vm.person,'age',20);

        vm.person = Object.assign({},vm.person,{age:10,address:'北京'})




    </script>
</body>
</html>